$(document).ready(function(){
	var queryAreaListFun = function(){
		var url = adminQueryUrl + queryAreaList;
		console.log('url='+url)
		var param = 'condiction=1';
		if ($("#areaName").val()!=''){
			param += "&areaName="+$("#areaName").val()
		}
		if ($("#areaCode").val()!=''){
			param += "&areaCode="+$("#areaCode").val()
		}
		$.post(url,param,function(data,status){
			console.log('data='+data);
			$('#areaDataGrid').empty();
			$('#areaDataGrid').data('zui.datagrid',null);
			$('#areaDataGrid').datagrid({
			    dataSource: {
			        cols:[
			            {name: 'areaCode', label: '地区编码', width: 132},
			            {name: 'areaName', label: '地区名称', width: 134},
			            {name: 'areaParentName', label: '上级地区名称', width: 109},
			            {name: 'sortNo', label: '排序码', width: 109},
			            {name: 'desc', label: '描述', width: -1},//-1用于自适应宽度
			            {name: 'target', label: '操作', width: 109}
			        ],
			        cache:false,
			        array:data
			    }
			});
			//获取分页
			$('#areaPager').pager({
			    page: 1,
			    recTotal: data.length,
			    elements:['first_icon', 'prev_icon', 'pages', 'next_icon', 'last_icon', 'total_text','size_menu','goto'],
			    pageSizeOptions:[10,20,30,50,100]
			});
			//$('#areaDataGrid').data('zui.datagrid').renderData();
		},"JSON");
	};
	queryAreaListFun();
	//获取列表数据
	/*
	 $('#areaDataGrid').datagrid({
	    dataSource: {
	        cols:[
	            {name: 'areaCode', label: '地区编码', width: 132},
	            {name: 'areaName', label: '地区名称', width: 134},
	            {name: 'areaParentName', label: '上级地区名称', width: 109},
	            {name: 'sortNo', label: '排序码', width: 109},
	            {name: 'desc', label: '描述', width: -1},//-1用于自适应宽度
	            {name: 'target', label: '操作', width: 109}
	        ],
	        states: {
	            pager: {
	            	page: 1, 
	            	recPerPage: 10,
	            	elements:['first_icon', 'prev_icon', 'pages', 'next_icon', 'last_icon', 'total_text','size_menu','goto'],
	        	    pageSizeOptions:[10,20,30,50,100]
	            }
	        },
	        remote: function(params) {
	        	console.log('params3='+params);
	        	console.log('adminQueryUrl + queryAreaList='+adminQueryUrl + queryAreaList);
	        	
	            return {
	                url: adminQueryUrl + queryAreaList,
	                // 请求类型
	                type: 'POST',
	                // 数据类型
	                dataType: 'json',
	                data:{
	                	'areaName':$("#areaName").val(),
	                	'areaCode':$("#areaCode").val(),
	                }
	            };
	        }
	    }
	});
	*/

	//搜索
	$("#searchBtn").click(function(){
		queryAreaListFun();
	});
	/*
	$("#searchBtn").click(function(){
		var url = adminQueryUrl + queryAreaList;
		var param = 'condiction=1';
		if ($("#areaName").val()!=''){
			param += "&areaName="+$("#areaName").val()
		}
		if ($("#areaCode").val()!=''){
			param += "&areaCode="+$("#areaCode").val()
		}
		$.post(url,param,function(data,status){
			console.log('data2='+data);
			
			var areaDataGrid = $('#areaDataGrid').data('zui.datagrid');
			$('#areaDataGrid').empty();
			console.log('areaDataGrid='+areaDataGrid)
			areaDataGrid.setDataSource(data);
			areaDataGrid.render();
			//areaDataGrid.renderData();
		},"JSON");
		
	});
	*/
	/*//获取分页
	$('#areaPager').pager({
	    page: 1,
	    recTotal: 1000,
	    elements:['first_icon', 'prev_icon', 'pages', 'next_icon', 'last_icon', 'total_text','size_menu','goto'],
	    pageSizeOptions:[10,20,30,50,100]
	});*/
});

